Custom Export to Word will not respect filter

I have written a fairly complicated script that is based off of the IBM scripts used to export modules to Microsoft Word. I have recently rewritten and reorganized the script, and it is now much easier to read. The only problem I'm having seems to be that when my script exports it doesn't respect the filter settings for the view I am exporting. At least, that's what it seems like to me. What I know for sure is that the view displays what I want it to in the Module, but when I export it I get an extra table that is supposed to be located in a different view. 

I have two views that my script is supposed to export. One view shows all of the objects up to object number 6.1, and the other view shows the rest, which is just a revision page table. This is necessary for multiple reasons, but the most prominent is Word limitations. At any rate, what I would like to know is what am I doing wrong that is causing that table to export along with the first view?

I am using the code below:

for o in document ModuleToExport do
{
        // IF the object cannot be read
        // - Paste the error into word
        // ENDIF
    if (!canRead o)
    {
                // Paste the data
                pasteToWord(richText NLS_("> ") (number o) NLS_(" (Read Locked Data)"), NS)

                // Skip to the next object
        continue
    }
        
    // IF the current object is a table
        // - Export the table to a word table
        // ELSE
        // - Export the object's heading/text to word
        // ENDIF
        if(table o)
        {
        ExportDOORSTableToWord(o)
        }
        else
        {
            // This code works fine
        }
}

Why does this loop return the table at the end of the module that should not be visible in the currently loaded view?

Thanks,

Greg


CMusicFan - Thu Oct 29 14:15:57 EDT 2015

Re: Custom Export to Word will not respect filter
DOORSHAM - Thu Oct 29 17:08:33 EDT 2015

Remove the word document in the for loop

Re: Custom Export to Word will not respect filter
CMusicFan - Fri Oct 30 08:37:39 EDT 2015

DOORSHAM - Thu Oct 29 17:08:33 EDT 2015

Remove the word document in the for loop

That loop would not return table objects at all. I still need the loop to return table objects. I just want the loop to respect the current filter. My problem is that the loop I am using seems to always return table objects, whether they are filtered or not.

Re: Custom Export to Word will not respect filter
CMusicFan - Fri Oct 30 11:06:29 EDT 2015

The solution I came up with was to change the loop to a "for object in module" loop. This causes table objects to not be returned, but cells are. So I used the cells to get the table object, kept track of the last table to export, and compared it to the current table. This ensures that only one table is exported. This seems like a roundabout way of doing things, but it seems to work for me.